package com.xiaozhaovip.demo.Enum;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

/**
 * 活动分类枚举类
 *
 * @author Cauli
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
public enum YueQiLaiCategoryEnum {
    All(0, "所有分类"),
    Learning(1, "学习"),
    Traveling(2, "旅行"),
    Sport(3, "运动"),
    Entertainning(4, "休闲娱乐"),
    Party(5, "聚会"),
    Others(6, "其他");

    private int id;
    private String name;

    /**
     * 通过 id 得到活动项
     *
     * @param id
     * @return
     */
    public static YueQiLaiCategoryEnum getById(int id) {
        for (YueQiLaiCategoryEnum categoryEnum : YueQiLaiCategoryEnum.values()) {
            if (id == categoryEnum.id) {
                return categoryEnum;
            }
        }
        return null;
    }

    /**
     * 返回所有分类
     *
     * @return
     */
    public static List<YueQiLaiCategoryEnum> getAllCategories() {
        List<YueQiLaiCategoryEnum> list = new ArrayList<>();
        for (YueQiLaiCategoryEnum categoryEnum : YueQiLaiCategoryEnum.values()) {
            list.add(categoryEnum);
        }
        return list;
    }
}
